package com.example.cadmin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.cadmin.entity.MyRoleUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author  zzsoft 
 * @since 2023-01-07
 */
public interface MyRoleUserMapper extends BaseMapper<MyRoleUser> {
    /**
     * 通过用户id查询权限id
     * @param userId
     * @return
     */
    @Select("select * from my_role_user ru where ru.user_id = #{userId}")
    List<MyRoleUser> getMyRoleUserByUserId(Integer userId);

    /**
     * 新建用户与角色表依赖
     * @param myRoleUser
     * @return
     */
    @Insert("insert into my_role_user(user_id, role_id) values(#{userId}, #{roleId})")
    int save(MyRoleUser myRoleUser);

}
